為什麼使用 py2app 模塊創建 mac 文件時出現錯誤? (Why i am getting Error when creating mac file using py2app module?)


問題描述

為什麼使用 py2app 模塊創建 mac 文件時出現錯誤? (Why i am getting Error when creating mac file using py2app module?)

我正在嘗試將 Tkinter python 文件轉換為 dmg 或 mac os 文件。但是,當我在終端中鍵入 python setup.py py2app ‑A 時,出現以下錯誤 *** 創建應用程序包:MyApplication *** 錯誤:[Errno 1] Operation not allowed: '/Users /mohamedthoufeeq/dist/MyApplication.app/Contents/MacOS/MyApplication' 請幫我解決這個問題。

Mohameds‑MacBook‑Pro:~ mohamedthoufeeq$ python setup.py py2app ‑A
running py2app
creating /Users/mohamedthoufeeq/build/bdist.macosx‑11.0‑x86_64/python2.7‑standalone/app
creating /Users/mohamedthoufeeq/build/bdist.macosx‑11.0‑x86_64/python2.7‑standalone/app/collect
creating /Users/mohamedthoufeeq/build/bdist.macosx‑11.0‑x86_64/python2.7‑standalone/app/temp
creating build/bdist.macosx‑11.0‑x86_64/python2.7‑standalone/app/lib‑dynload
creating build/bdist.macosx‑11.0‑x86_64/python2.7‑standalone/app/Frameworks
*** creating application bundle: MyApplication ***
error: [Errno 1] Operation not permitted: '/Users/mohamedthoufeeq/dist/MyApplication.app/Contents/MacOS/MyApplication'

參考解法

方法 1:

Four possible answers:

  1. Write python3 instead of python
  2. Disable SIP as it may mess with the permission end (what your error suggests)

Reboot the Mac and hold down Command + R keys simultaneously after you hear the startup chime, this will boot Mac OS X into Recovery Mode When the “MacOS Utilities” / “OS X Utilities” screen appears, pull down the ‘Utilities’ menu at the top of the screen instead, and choose “Terminal” Type the following command into the terminal then hit return:

csrutil disable; reboot

You’ll see a message saying that System Integrity Protection has been disabled and the Mac needs to restart for changes to take effect, and the Mac will then reboot itself automatically, just let it boot up as normal

  1. Remove the restricted File Flag

sudo chflags ‑R norestricted /System/Library/Frameworks/Python.framework

  1. Uninstall py2app and reinstall it

pip3 uninstall py2ap

pip3 install ‑U py2app

(by ThoufeeqAltay Akkus)

參考文件

  1. Why i am getting Error when creating mac file using py2app module? (CC BY‑SA 2.5/3.0/4.0)

#Python #py2app






相關問題

如何從控制台中導入的文件中訪問變量的內容? (How do I access the contents of a variable from a file imported in a console?)

在 python 3.5 的輸入列表中添加美元符號、逗號和大括號 (Adding dollar signs, commas and curly brackets to input list in python 3.5)

為 KeyError 打印出奇怪的錯誤消息 (Strange error message printed out for KeyError)

django 1.9 中的 from django.views.generic.simple import direct_to_template 相當於什麼 (What is the equivalent of from django.views.generic.simple import direct_to_template in django 1.9)

查詢嵌入列表中的數組 (Querying for array in embedded list)

如何在 Python 中搜索子字符串是否在二進製文件中? (How to search if a substring is into a binary file in Python?)

為什麼要避免 while 循環? (Why avoid while loops?)

使用python的json模塊解析json請求 (Parse a json request using json module of python)

為什麼使用 py2app 模塊創建 mac 文件時出現錯誤? (Why i am getting Error when creating mac file using py2app module?)

當 python 線程在網絡調用(HTTPS)中並且發生上下文切換時會發生什麼? (What happens when the python thread is in network call(HTTPS) and the context switch happens?)

如何繪製一條帶斜率和一個點的線?Python (How to plot a line with slope and one point given? Python)

Pickle 找不到我不使用的模塊? (Pickle can't find module that I am not using?)







留言討論